package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.FrameBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

public class FrameAdapter extends StkProviderMultiAdapter<FrameBean> {
    public FrameAdapter() {
        super(8);
        addItemProvider(new FrameItemProvider());
    }

    private class FrameItemProvider extends BaseItemProvider<FrameBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_color;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, FrameBean frameBean) {
            baseViewHolder.setBackgroundColor(R.id.tvColorItemBg, Color.parseColor(frameBean.getFrameColor()));
            baseViewHolder.setVisible(R.id.ivColorItemSel, frameBean.isSelected());
            if (frameBean.getFrameColor().equals("#000000")) {
                baseViewHolder.setVisible(R.id.ivColorItemBlack, true);
            } else {
                baseViewHolder.setVisible(R.id.ivColorItemBlack, false);
            }
        }
    }
}
